<template>
  <el-tree
      style="max-width: 600px"
      :props="props"
      :load="loadNode"
      lazy
  />
</template>

<script setup>
import { treeSelect } from "@/api/user/region";

const props = {
  label: 'name',
  children: 'zones',
  isLeaf: 'leaf',
}
const parentCode = ref(0)

const loadNode = async (node,resove) => {
  if (node.data.code){
    parentCode.value = node.data.code
  }
  const {data} = await treeSelect(parentCode.value).then()
  data.forEach(item=>{
    item.leaf = item.level ==3 ? true : false
  })
  resove(data)
}
</script>


